--[[/**
-- * 

 * 变鸡buff (效果)
-- *
-- */]]

---@class BuffEffect225102 : BaseBuffEffect
BuffEffect225102 = ClientFight.CreateClass("BuffEffect225102", ClientFight.BaseBuffEffect)
local t = BuffEffect225102
t.BUFF_EFFECT_225102_LAST_RANDOM = "BUFF_EFFECT_225102_LAST_RANDOM";
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    t:randomPoint(fight, buff, buff.target);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. "增加能量(" .. buff.buffBean.f_BuffEffectValue[1] .. ")");
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end
function t:add(fight, buff)
    t:randomPoint(fight, buff, buff.target);
    return ClientFight.BaseBuffEffect.add(self, fight, buff);

end

function t:randomPoint(fight, buff, fighter)
    local list = { 1, 2, 3, 4 };
    local lastRandom = buff.effectParams[t.BUFF_EFFECT_225102_LAST_RANDOM] or 0;
    table.remove(list, table.containsIndex(list, lastRandom))

    local random = list[fight.random(table.getn(list))];
    local pos = t:createPos(random);
    fighter.movePosition = pos;

    ReportManager.setMoveEndToJsonString(fight, fighter, fighter.moveAction);
    fighter.moveAction = ReportManager.moveToJsonString(fight, fighter)
    table.insert(fight.actions, clone(fighter.moveAction))
    FightManager.playActions(fighter.moveAction)

    buff.effectParams[t.BUFF_EFFECT_225102_LAST_RANDOM] = random;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s变鸡buff %s 变更目的地为%s",
            fight.frame, fighter.fighterId, buff.modelId, pos
    ));
end

function t:createPos(type)
    local centerX = (Global.FIGHT_INNER_ROUND[1][1] + Global.FIGHT_INNER_ROUND[2][1]) / 2;
    local centerY = (Global.FIGHT_INNER_ROUND[1][3] + Global.FIGHT_INNER_ROUND[2][3]) / 2;
    if type == 1 then
        return Vector2.New(Global.FIGHT_INNER_ROUND[1][1], centerY);
    elseif type == 2 then

        return Vector2.New(Global.FIGHT_INNER_ROUND[2][1], centerY);
    elseif type == 3 then
        return Vector2.New(centerX, Global.FIGHT_INNER_ROUND[1][3]);
    else
        return Vector2.New(centerX, Global.FIGHT_INNER_ROUND[2][3]);
    end
end
t.New()